﻿@using CleanArchitecture.Infrastructure.Entities
@using CleanArchitecture.Infrastructure.Entities.System.DataDic
@using CleanArchitecture.Infrastructure.Models.SystemManage
@model SystemDataDicTreeSearchModel
@{
    var datadictreeRoots = Model.CustomProperties["datadictreeRoots"] as IList<SystemDataDicTree> ?? null;
    var OrganizeGroup = datadictreeRoots.FirstOrDefault(m => m.GroupType == EntityEnumConfig.DataDicGroup.Oragnize);
}
<form class="layui-form layui-hide" id="@OrganizeGroup.GroupType.ToString()">
    <fieldset class="layui-elem-field">
        <legend>组织机构设置</legend>
        <div class="layui-field-box pagebuttongroup">
            @await Component.InvokeAsync("PageButton")
        </div>
    </fieldset>

    <table id="organizetreetable" lay-filter="organizetreetable"></table>
</form>

<script type="text/javascript">
    var organizetableconfig = {
        elem: "#organizetreetable",
        url: '/api/system/getsystemdatadictree?grouptype=@((int)OrganizeGroup.GroupType)',
        contentType: 'application/json;charset=UTF-8',
        tree: {
            iconIndex: 1,     // 折叠图标显示在第几列
            isPidData: false, // 是否是pid形式数据
            openName: 'spread'
        },
        cols: [
            { field: 'id', title: 'ID', width: 30 },
            { field: 'title', title: '机构名称' },
            {
                field: 'grouptype', title: '分类', width: 80,
                templet: function (d) {
                    if (d.grouptype === 1) return '组织机构';
                    else return '';
                }
            },
            {
                field: 'datatype', title: '数据类型', width: 200,
                templet: function (d) {
                    if (d.datatype === 11) return '站点';
                    else if (d.datatype === 12) return '区域审核';
                    else if (d.datatype === 13) return '站务中心审核';
                    else if (d.datatype === 14) return '党群中心审核';
                    else return '';
                }
            },
            { field: 'displayorder', title: '排序', width: 80, templet: "#displayorderTpl" },
            { title: '操作', minWidth: 100, templet: '#tableitemBars', fixed: "right", align: "center" }
        ],
        parseData: function (res) {
            return {
                "code": res.state == 200 ? 0 : -1,     //解析接口状态
                "msg": res.message,     //解析提示文本
                "count": res.state == 200 ? res.data.length : 0, //解析数据长度
                "data": res.state == 200 ? res.data : []  //解析数据列表
            };
        },
        page: false
    };
</script>
